﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace Maticsoft.Web.TableInfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int TId=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(TId);
				}
			}
		}
			
	private void ShowInfo(int TId)
	{
		Maticsoft.BLL.TableInfo bll=new Maticsoft.BLL.TableInfo();
		Maticsoft.Model.TableInfo model=bll.GetModel(TId);
		this.lblTId.Text=model.TId.ToString();
		this.txtTTitle.Text=model.TTitle;
		this.txtTHallId.Text=model.THallId.ToString();
		this.chkTIsFree.Checked=model.TIsFree;
		this.chkTIsDelete.Checked=model.TIsDelete;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtTTitle.Text.Trim().Length==0)
			{
				strErr+="TTitle不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtTHallId.Text))
			{
				strErr+="THallId格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int TId=int.Parse(this.lblTId.Text);
			string TTitle=this.txtTTitle.Text;
			int THallId=int.Parse(this.txtTHallId.Text);
			bool TIsFree=this.chkTIsFree.Checked;
			bool TIsDelete=this.chkTIsDelete.Checked;


			Maticsoft.Model.TableInfo model=new Maticsoft.Model.TableInfo();
			model.TId=TId;
			model.TTitle=TTitle;
			model.THallId=THallId;
			model.TIsFree=TIsFree;
			model.TIsDelete=TIsDelete;

			Maticsoft.BLL.TableInfo bll=new Maticsoft.BLL.TableInfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
